const Koa = require('koa');
const { initRouter, initController, initService, initSchedule, initConfig } = require('./mainLoader');

class App {
    constructor(conf){
        this.$app = new Koa(conf);

        initConfig(this);

        this.$service = initService(this);

        this.$ctrl = initController();

        this.$router = initRouter(this);

        this.$app.use(this.$router.routes());

        initSchedule();

        
    }

    start(port=3000){
        this.$app.listen(port,()=>{
            console.log(`server is run at ${port}...`);
        })
    }
}

module.exports = App;